package com.marvin.controller;

import com.marvin.core.Blog;
import com.marvin.service.IBlogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author yinyin
 * @create 2021/11/16 下午 5:51
 */
@Controller
public class BlogDetailController {
    @Autowired
    private IBlogService blogService;

    @GetMapping("blogDetail/{blogId}")
    public ModelAndView getBlogDetail(@PathVariable Integer blogId ){
        ModelAndView modelAndView = new ModelAndView();
        Blog blog = blogService.getById(blogId);
        modelAndView.addObject("blogDetail",blog);
        modelAndView.setViewName("blog/detail");
        return modelAndView;
    }
}
